package com.test.ftp;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

public class MyProp {
	public static MyProp myprop;
	public Properties property;

	public static MyProp getInstance() {
		if (myprop == null) {
			myprop = new MyProp();
			myprop.property = new Properties();
			try {
				System.out.println(Constant.PROJECT_PATH);
				File f = new File(Constant.PROJECT_PATH,
						Constant.PROJECT_FILENAME);
				myprop.property.load(new FileInputStream(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return myprop;
	}

	public void setProp(String name, String value) {
		property.setProperty(name, value);
	}

	public String getProp(String name) {
		return property.getProperty(name);
	}

	public String getProp(String name, String default1) {
		return property.getProperty(name) == null ? default1 : property
				.getProperty(name);
	}
}
